package com.activity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.api.param.StoreParam;
import com.api.viewModel.StoreVM;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.activity.setting.WebViewActivity;
import com.example.apple.ddhr_new.activity.widget.Dialog;
import com.example.apple.ddhr_new.utils.ActivityUtil;

public class WebActivity extends WebViewActivity<StoreVM> {


    @Override
    protected void created(@Nullable Bundle savedInstanceState) {
        super.created(savedInstanceState);


        if(title.equals("考勤报表")){

            setImageRight(R.drawable.baobiao);
        }
        if(title.equals("外出报表")){

            setImageRight(R.drawable.baobiao);
        }
        if(title.equals("加班报表")){

            setImageRight(R.drawable.baobiao);
        }
        viewModel.attanceSign.observe(this,res->{

            ActivityUtil.startActivity(this,ExportActivity.class,getIntent().getExtras());
        });
        viewModel.outgoingsign.observe(this,res->{

            ActivityUtil.startActivity(this,ExportActivity.class,getIntent().getExtras());
        });
        viewModel.otsign.observe(this,res->{

            ActivityUtil.startActivity(this,ExportActivity.class,getIntent().getExtras());
        });

    }
    @Override
    protected void titleRightClick() {


        Dialog.alert(this, "导出确认", "", new Dialog.OnDialogOkClickListener() {
            @Override
            public void onClick(Object o) {

            }
        }, new Dialog.OnDialogOkClickListener() {
            @Override
            public void onClick(Object o) {

                if(title.equals("考勤报表")){

                    StoreParam storeParam = new StoreParam();
                    storeParam.storeno = App.getInstance().userstoreinfoBean.getStoreno();
                    addSubscription(viewModel.addattendanceSign(storeParam));
                }
                if(title.equals("外出报表")){

                    StoreParam storeParam = new StoreParam();
                    storeParam.storeno = App.getInstance().userstoreinfoBean.getStoreno();
                    addSubscription(viewModel.outgoingsign(storeParam));
                }
                if(title.equals("加班报表")){

                    StoreParam storeParam = new StoreParam();
                    storeParam.storeno = App.getInstance().userstoreinfoBean.getStoreno();
                    addSubscription(viewModel.otsign(storeParam));
                }



            }
        });
    }

}
